home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / mac / DOS / CAD_CAM / WCEDT202 / WC.LSP < prev    next >
Lisp/Scheme  |  1992-08-29  |  30KB  |  903 lines

  1. ;;;**************************************************************************
  2. ;;;   WC.LSP
  3. ;;;   (C) 1992 by ELSA America, Inc.
  4. ;;;
  5. ;;;   A part of the
  6. ;;;           WCEDIT  -- ADS Programable text editor.
  7. ;;;
  8. ;;;   Conceived and implemented by:
  9. ;;;           Walt Craig
  10. ;;;           Oct 1991
  11. ;;;
  12. ;;;**************************************************************************
  13. ;;;
  14. ;;;   WALT CRAIG PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. WALT CRAIG
  15. ;;;   SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR
  16. ;;;   FITNESS FOR A PARTICULAR USE.  WALT CRAIG DOES NOT WARRANT THAT
  17. ;;;   THE OPERATION OF THE PROGRAM WILL BE UNNINTERRUPTED OR ERROR FREE.
  18. ;;;
  19. ;;;**************************************************************************
  20. ;;;
  21. ;;; DESCRIPTION
  22. ;;;
  23. ;;;   WC.LSP is the loader for WCEDIT. Upon loading, a configuration
  24. ;;;   file is loaded. The function (WCconfig ) defineds
  25. ;;;   the keys and (wc_setvar) sets various variables.
  26. ;;;
  27. ;;;   System control is shared and passed between C:WC and WCEdit
  28. ;;;   to provide a method in which to 'drive' WCEdit within AutoCAD.
  29. ;;;
  30. ;;;   Note:
  31. ;;;      Altering the functions C:WC, PROCESS or WCERR is not recommended.
  32. ;;;
  33. ;;;**************************************************************************
  34. (if(not WCedit)                     ;If it's not already defined
  35.    (progn                           ;
  36.       (xload "WCedit")              ;Then xload it in
  37.    )
  38. )
  39. ;------------------ Main calling function -----------------------------------
  40. (defun c:WC( / __lst__ __nme__)
  41.    (setq __nme__ (list 0 ""))     ;Force to the loop to enter
  42.    (setq __olderr__ *error* *error* WCerr);Set the error to return to the editor
  43.    (while(and(listp __nme__)__nme__)   ;While nme is a list with a value
  44.       (setq *error* WCerr)             ;Set the error to return to the editor
  45.       (setq __nme__(WCedit))           ;Call the editor with no parameters
  46.       (if (and (listp __nme__) __nme__);If the exit code is a list with a value
  47.          (process __nme__)     ;Then call the lisp routine 'process' sending the
  48.       )                        ;list of (scancode "lisp function name")
  49.    )
  50.    (setq *error* __olderr__)   ;Kill errors from returning to the editor
  51. ;  (graphscr)                  ;Remout this line if ya want.
  52.    (if (= (type __nme__) 'STR) ;If nme is a string then We'll run it!
  53.       (progn
  54.          (eval(list(read __nme__))) ;Run the routine
  55.          (command "script" "wcrld");If No errors , then we'll return
  56.       )
  57.    )
  58.    (prin1)
  59. );End of WC program
  60. ;-------------------- Process function evaluator ----------------------------
  61.  
  62. ;-------------------- __mykey__ is a global ---------------------------------
  63. (defun process(__stuff__  / __name__)      ;Figure out what to do
  64.    (setq __mykey__(car __stuff__))    ;This is scancode for the key you hit
  65.    (setq __name__(cadr __stuff__))    ;This is the name of the lisp func as a string
  66.    (if (not (listp (read __name__)))
  67.       (progn
  68.          (if (not(eval(read __name__))) ;Test to see if it is defined before evaluating
  69.             (WC_message (strcat "Function: " __name__ " is not defined!")0)
  70.             (eval(list(read __name__))) ;Run the routine
  71.          )
  72.       )
  73.       (progn
  74.          (eval(read __name__)) ;Run the routine
  75.       )
  76.    )
  77.    (prin1)
  78. );End of the process routine
  79. ;---------------------- Wc error routine ------
  80. (defun WCerr(msg)          ;This is the error routine
  81.    (setq globalerr msg        ;Save a copy of error to refer back to
  82.       *error* __olderr__
  83.    )
  84.    (if wcedit
  85.       (progn
  86.          (setvar "CMDECHO" 0)
  87.          (command "script" "wcrld")
  88.          (wc_message (strcat "AutoLISP *error*: " (strcase msg nil)) 0)
  89.       )
  90.    )
  91.    (prin1)
  92. );End of the WCerr routine
  93.  
  94. ;*********************** ALL Functions listed below may be modified ********
  95. ;******************* to suit your needs ************************************
  96. (wcconfig "(wc_toggle \"TOCASE\")" 1.0 "Toggle case sensitivity")
  97.  
  98. ;;;Deletes a window by a double key stroke action where the
  99. ;;;arrow key must coincide with the edge of a window to be
  100. ;;;deleted. This is used explicitly for the Brief configuration.
  101. (defun delwin()
  102.    (setq way(nth 14 (wc_statistics)))
  103.    (if(/= way 0)
  104.       (progn
  105.          (wc_print "Select window edge to delete (use cursor).")
  106.          (setq a(wc_message "" 0))
  107.       )
  108.    )
  109.    (cond
  110.       ((or (= way 1)(= way 2))
  111.          (if(or(= (wc_gname a) "Right")(= (wc_gname a) "Left"))
  112.             (wc_trigger "MAKE_ONE")
  113.             (wc_print "Edge does not have a window")
  114.          )
  115.       )
  116.       ((or (= way 3)(= way 4))
  117.          (if(or(= (wc_gname a) "Up")(= (wc_gname a) "Down"))
  118.             (wc_trigger "MAKE_ONE")
  119.             (wc_print "Edge does not have a window")
  120.          )
  121.       )
  122.       (t
  123.          (wc_print "Edge does not have a window")
  124.       )
  125.    )
  126. )
  127. (wcconfig "delwin" 1.0 "Delete window edge")
  128.  
  129. ;;;Opens  a window by a double key stroke action where the
  130. ;;;arrow key determines the direction by which to open the
  131. ;;;window. Used explicitly by Brief.lsp.
  132. (defun splitc()
  133.    (wc_print "Select side for new window (use cursor).")
  134.    (setq a(wc_message "" 0))
  135.    (cond
  136.       ((or (= (wc_gname a) "Right")(= (wc_gname a) "Left"))
  137.          (wc_trigger "SPLIT_CENTER_U")
  138.          (wc_refresh 1)
  139.       )
  140.       ((or (= (wc_gname a) "Up")(= (wc_gname a) "Down"))
  141.          (wc_trigger "SPLIT_CENTER_R")
  142.          (wc_refresh 1)
  143.       )
  144.       (t
  145.          (wc_print " ")
  146.       )
  147.    )
  148. )
  149. (wcconfig "splitc" 1.0 "Open window")
  150.  
  151. ;;;This sets up the book markers for use with gbmark and sabmark.
  152. (defun sbmark()
  153.    (setq __bmark(list
  154.          '(1 (nil nil))
  155.          '(2 (nil nil))
  156.          '(3 (nil nil))
  157.          '(4 (nil nil))
  158.          '(5 (nil nil))
  159.       )
  160.    )
  161. )
  162.  
  163. ;;;Jump to previously saved book mark <position in file>
  164. (defun gbmark()
  165.    (if(not __Bmark)
  166.       (sbmark)
  167.    )
  168.    (setq j(wc_fetch_int "Go to Bookmark [1-5]: " 1 1))
  169.    (setq old (cadr(assoc j __bmark)))
  170.    (if (or (not( nth 0 old)) (not (nth 1 old)))
  171.       (progn
  172.          (wc_beep 5000.0 9000.0)
  173.          (wc_print "That Bookmark doesn't exist.")
  174.       )
  175.       (progn
  176.          (wc_row (nth 0 old))
  177.          (wc_col (nth 1 old))
  178.          (wc_refresh 1)
  179.          (wc_print (strcat "Bookmark "(itoa j)" restored."))
  180.       )
  181.    )
  182. )
  183.  
  184. ;;;Save bookmark <position in file>
  185. (defun sabmark(/ old new)
  186.    (if(not __Bmark)
  187.       (sbmark)
  188.    )
  189.    (setq ky __mykey__)
  190.    (cond
  191.       ((= __mykey__  (wc_gkey "Alt 1"))
  192.          (setq k 1)
  193.       )
  194.       ((= __mykey__  (wc_gkey "Alt 2"))
  195.          (setq k 2)
  196.       )
  197.       ((= __mykey__  (wc_gkey "Alt 3"))
  198.          (setq k 3)
  199.       )
  200.       ((= __mykey__  (wc_gkey "Alt 4"))
  201.          (setq k 4)
  202.       )
  203.       ((= __mykey__  (wc_gkey "Alt 5"))
  204.          (setq k 5)
  205.       )
  206.       (t (setq k nil))
  207.    )
  208.    (if k
  209.       (progn
  210.          (setq old (assoc k __bmark))
  211.          (setq new (list k (list (wc_row -1)(wc_col -1))))
  212.          (setq __bmark(subst new old __bmark))
  213.          (wc_print (strcat "Bookmark "(itoa k)" saved."))
  214.       )
  215.    )
  216. )
  217.  
  218. (defun rem_spaces(str / i ch outstr)
  219.    (wc_trimends str)
  220. )
  221.  
  222. ;;;This is used to toggle the insert mode on/off
  223. (defun togins()
  224.    (wc_toggle "INSERT_MODE")
  225. )
  226.  
  227. ;;;This simply returns the current/active file name.
  228. (defun gcname()
  229.    (setq lst(wc_statistics)one(nth 0 lst)two (nth 1 lst)side(nth 14 lst))
  230.    (cond
  231.       ((or (= side 0)(= side 2)(= side 4))
  232.          one
  233.       )
  234.       (t two)
  235.    )
  236. )
  237.  
  238. ;;;This function simply displays the current filename as a print.
  239. (defun disp_fname()
  240.    (wc_print gcname)
  241.    (prin1)
  242. )
  243.  
  244. ;;;This will either bring up the file passed as the current file and
  245. ;;;return 't or nil if the file is not loaded into WCEdit.
  246. (defun tog_to_name(name / i nbuffs)
  247.    (setq nbuffs(nth 13 (wc_statistics))i 0)
  248.    (setq name (strcase name nil));Make the case upper.
  249.    (setq name (rem_spaces name));REmove any trailing spaces
  250.    (while (and (< i nbuffs)(/= name (gcname)))
  251.       (wc_trigger "TOGGLE_FILE")
  252.       (setq i (+ 1 i))
  253.    )
  254.    (if( = name (gcname))
  255.       't
  256.       nil
  257.    )
  258. )
  259.  
  260. ;;;This will 'zap' the file called by name from WCEdit. WARNING! Use
  261. ;;;this function with care since it does not check for file upsets.
  262. (defun zap_name(name)
  263.    (if(tog_to_name name)
  264.       (progn
  265.          (setq i(nth 18 (wc_statistics)))
  266.          (wc_trigger "TOGGLE_FILE")
  267.          (if(= i (nth 18 (wc_statistics)))
  268.             (progn
  269.                (wc_silent 0)
  270.                (wc_message "Attempted to delete last buffer!" 0)
  271.                (quit)
  272.             )
  273.             (wc_remove_buffer i)
  274.          )
  275.       )
  276.       (progn
  277.          (wc_silent 0)
  278.          (wc_message "Name does not exist!" 0)
  279.          (quit)
  280.       )
  281.    )
  282. )
  283.  
  284.  
  285. ;;;This is just a little fun I've thrown in.
  286. (defun shave()
  287.    (WC_message "Shave and a hair cut .... " 1)
  288.    (WC_shave)
  289.    (WC_refresh 1)
  290. )
  291. (wcconfig "shave" 1.0 "Shave and a Hair cut")
  292.  
  293. ;;;Use this routine for file checking if needed. The routine
  294. ;;;will look to see if the file 'name' exists. If it does
  295. ;;;exist, then a message appears asking the user if he/she
  296. ;;;wants to overwrite. The function returns 't if ok to
  297. ;;;overwrite or nil for not ok.
  298. (defun check_file(name)
  299.    (setq answer 't)
  300.    (if name
  301.       (progn
  302.          (if(findfile name)
  303.             (progn
  304.                (setq answer(WC_message "File exists! Overwrite? N" 0))
  305.                (if answer
  306.                   (progn
  307.                      (setq answer(WC_castchar answer))
  308.                      (if(or(= answer "Y")(= answer "y"))
  309.                         (setq answer 't)
  310.                         (setq answer nil)
  311.                      )
  312.                   )
  313.                )
  314.             )
  315.          )
  316.       )
  317.       (setq answer nil)
  318.    )
  319.    answer
  320. )
  321.  
  322. ;;;Register the function 'CHECKOUT' to a key...this thing is the neatest
  323. ;;;little thing I've come with in a long time! Should sell it!
  324. ;;;After you've registered it to a key move the cursor to anything your
  325. ;;;curious about, <a variable, list, whatever>. Then hit the key you've
  326. ;;;registered it to and the message window will pull up with a little
  327. ;;;info about that thing...you'll love it!
  328. (defun symstr(sym / fp a)
  329.    (princ sym(setq fp(open "$$TRASH.$@1" "w")))
  330.    (close fp)
  331.    (setq a(read-line(setq fp(open "$$TRASH.$@1" "r"))))
  332.    (close fp)
  333.    (eval a)
  334. )
  335.  
  336. (defun checkout(/ value first thing pt)
  337.    ;(setq pt(wc_prev_word))
  338.    (setq pt(wc_next_word))
  339.    (setq value(eval(read pt)) first(strcat "[" pt "]: "))
  340.    (cond
  341.       ((= (type value) 'sym)
  342.          (setq thing (strcat first "SYM  = "(symstr value)))
  343.       )
  344.       ((= (type value) 'list)
  345.          (if pprint
  346.             (setq thing (pprint value nil) thing nil)
  347.             (setq thing (strcat  first "LIST  = "(symstr value)))
  348.          )
  349.       )
  350.       ((= (type value) 'file)
  351.          (setq thing (strcat  first "FILE  = "(symstr value)))
  352.       )
  353.       ((= (type value) 'subr)
  354.          (setq thing (strcat  first "SUBR  = "(symstr value)))
  355.       )
  356.       ((= (type value) 'exsubr)
  357.          (setq thing (strcat  first "EXSUBR  = "(symstr value)))
  358.       )
  359.       ((= (type value) 'PICKSET)
  360.          (setq thing (strcat  first "PICKSET  = "(symstr value)))
  361.       )
  362.       ((= (type value) 'ENAME)
  363.          (setq thing (strcat  first "ENAME  = "(symstr value)))
  364.       )
  365.       ((= (type value) 'PAGETB)
  366.          (setq thing (strcat  first "PAGETB = "(symstr value)))
  367.       )
  368.       ((= (type value) 'REAL)
  369.          (setq thing (strcat  first "REAL = "(rtos value 2 2)))
  370.       )
  371.       ((= (type value) 'INT)
  372.          (setq thing (strcat  first "INT = "(itoa value)))
  373.       )
  374.       ((= (type value) 'STR)
  375.          (setq thing (strcat  first "STR = " "\"" value "\""))
  376.       )
  377.       ((= (type value) nil)
  378.          (setq thing (strcat  first "Is nil" ))
  379.       )
  380.    )
  381.    (if thing
  382.       (progn
  383.       (wc_stuffkey (wc_gkey "Home"))
  384.       (wc_fetch_string (strcat thing
  385.          "")
  386.          " Evaluates to: "
  387.       " Escape Exits ")
  388.       )
  389.    )
  390. )
  391. (wcconfig "checkout" 1.0 "Evaluate the next AutoLISP expression")
  392.  
  393. ;;;ETOS function from Inside Autolisp
  394. (defun etos (arg / file)
  395.    (if (= 'STR (type arg))
  396.       (setq arg (strcat "\"" arg "\""))
  397.    )
  398.    (setq file (open "$" "w"))
  399.    (princ arg file)
  400.    (close file)
  401.    (setq file (open "$" "r"))
  402.    (setq arg (read-line file))
  403.    (close file)
  404.    (close (open "$" "w"))
  405.    arg
  406. );defun
  407.  
  408. ;This function is for direct access to AutoLISP.
  409. (defun eval_func (/ rep tmp)
  410.    (if (not _last_eval_)
  411.       (setq _last_eval_ "")
  412.    )
  413.    (setq rep (wc_fetch_string _last_eval_ "Enter function to evaluate:" ""))
  414.    (if rep
  415.       (progn
  416.          (setq _last_eval_ rep)
  417.          (setq tmp (eval (read rep)))
  418.          (if tmp
  419.             (progn
  420.                (setq tmp (etos tmp)) ; converts whatever is returned to a string
  421.                (if tmp
  422.                   (wc_fetch_string tmp "Lisp evaluation returned: " "Press <ESC> to continue" )
  423.                )
  424.             )
  425.          )
  426.       )
  427.    )
  428. )
  429. (wcconfig "eval_func" 1.0 "Access AutoLISP directly")
  430.  
  431. ;;;This routine is used for returning the scancode value of a key pressed. The
  432. ;;;routine  will  ask  you for a string/comment of the key and then ask you to
  433. ;;;hit  that  key.  It  will then place the scancode value for that key at the
  434. ;;;current  cursor  position followed by ');' and the comment previously typed
  435. ;;;in.  This  function  should  be  played  with  to  obtain a method which is
  436. ;;;comfortable for you.
  437. (defun getcode();/ lst str key line col SS)
  438.    (WC_refresh 0)
  439.    (if (not _last_code_name_)
  440.       (setq _last_code_name_ "")
  441.    )
  442.    (setq lst(WC_statistics))
  443.    (setq line(WC_row -1.0))
  444.    (setq col (WC_col -1.0))
  445.    (setq key(WC_message "Hit key --> " 0))
  446.    (setq sS (wc_gname key))
  447.    (if ss
  448.       (setq str(strcat " (WC_gkey \""(wc_gname key) "\")" ))
  449.       (setq str (RTOS key 2 0))
  450.    )
  451.    (WC_silent 0)
  452.    (WC_trigger "INSERT_LINE_A")
  453.    (WC_replace_line str);Replaces the line
  454.    (WC_race_home 0)
  455.    (WC_trigger "BEGIN_COL_MARK")       ;Set a line mark
  456.    (WC_race_end 0)
  457.    (WC_trigger "END_MARK")             ;Set the end mark
  458.    (WC_trigger "BCUT")     ;Save the marked text
  459.    (WC_row line)
  460.    (WC_col col)
  461.    (WC_move_down 1.0)
  462.    (WC_trigger "DUMP_SCRAP")
  463.    (WC_row line )
  464.    (WC_col col)
  465.    (WC_trigger "DELETE_LINE")
  466.    (WC_refresh 0)
  467.    (prin1)
  468. )
  469. (wcconfig "getcode" 1.0 "Insert the ascii/scan code for a key")
  470.  
  471. ;;;This function will do the following:
  472. ;;;   1.)Check all brackets.
  473. ;;;   2.)If brackets are ok, then write the file to disk.
  474. ;;;   3.)If 1 and 2 are ok then load the file.
  475. (defun force_load(/ lst ls sd fname oldcomm oldjump check);This routine is used to
  476.    (setq lst(WC_STATISTICS))                    ;assist you in your lisp
  477.    (if lst                                      ;developemnt. While writing
  478.       (progn                                    ;your code you may hit CNT_L
  479.          (setq sd(nth 14 lst))                  ;and your function will be
  480.          (setq fname (gcname))                  ;bracket/string checked,
  481.          ;saved to file and loaded
  482.          ;back into AutoCAD.
  483.          ;Use the function 'add_name'
  484.          ;F8 to place your routine on
  485.          (if (not _IGNORE_)
  486.             (setq check(WC_trigger "DO_ALL_BRACKET"))
  487.          )
  488.          (if( = check 1)
  489.             (progn
  490.                (WC_message (strcat "Please wait loading " fname) 1)
  491.                (WC_HARD_WRITE)
  492.                (load fname "WCerr")
  493.                (WC_refresh 1)
  494.                (WC_print (strcat fname " is reloaded"))
  495.                ;(wc_trigger "QUIT") Optional
  496.             )
  497.             (WC_message "Unmatch parenthesis!" 0)
  498.          )
  499.       )
  500.    )
  501. )
  502. (wcconfig "force_load" 1.0 "Inspect write and load the current AutoLISP file")
  503.  
  504. ;;; add_name <currently assigned to F8> now selects a default function
  505. ;;; name as the first name after the first defun found from the current
  506. ;;; cursor position. Simply place the cursor on the line , or above,
  507. ;;; of the function and hit F8. Add_name should find the appropriate
  508. ;;; name to use for the default or nothing if it could not find a
  509. ;;; a 'defun'. REGISTER.
  510. (defun add_name(/ flag str a)
  511.    (WC_race_home 0)
  512.    (setq flag 't)
  513.    ;  (WC_set_words 41 125); <<-- Excludes any parenthesis
  514.    (setq oldcase(WC_getvar "TOCASE"))
  515.    (WC_setvar "tocase" 0)
  516.    (if( = (wc_find "defun") 1)
  517.       (progn
  518.          (setq str(WC_next_word))
  519.          (WC_setvar "tocase" oldcase)
  520.          (setq str(WC_FETCH_STRING str " Enter Lisp name " ""))
  521.          (if str
  522.             (progn
  523.                (setq a(WC_message "Enter Your Define key" 0))
  524.                ;(setq a(atoi(rtos a 2 2)));Forces to int if it's a real
  525.                (if (and a(/= a (wc_gkey "Escape")))
  526.                   (progn
  527.                      (WCconfig str a)
  528.                      (if (not(eval(read str))) ;Test to see if it is defined
  529.                         (WC_message "You must load before activating!" 0)
  530.                      )
  531.                      (WC_message "Function is Registered" 0);
  532.                   )
  533.                   (progn
  534.                      (if (= a (wc_gkey "Escape"))
  535.                         (WC_print "User canceled")
  536.                      )
  537.                      (if (> (strlen (WC_castchar a)) 0)
  538.                         (WC_message "Should not use alfa numeric keys for defines" 0)
  539.                      )
  540.                   )
  541.                )
  542.             )
  543.          )
  544.       )
  545.    )
  546. )
  547. (wcconfig "add_name" 1.0 "Register the next function to WCEdit")
  548.  
  549. ;;;I like to use this function to "kick" strings to the right since
  550. ;;;I prefer working with insert mode off. The routine will place
  551. ;;;the current tabwidth's amount of spaces at the cursor position.
  552. (defun intab(/ mode str tabw ch)
  553.    (setq mode(WC_getvar "insert_mode") str "" tabw (WC_getvar "TABWIDTH"))
  554.    (WC_silent 1)
  555.    (wc_race_home 0)
  556. ;  (wc_trigger "NEXT_WORD")
  557.  
  558.    (WC_pad_left tabw)
  559.    (WC_move_down 1.0)
  560.    (WC_race_home 0.0)
  561.    (WC_silent 0)
  562.    (WC_refresh 0);Resets silent to 0
  563. )
  564. (wcconfig "intab" 1.0 "Insert TABWIDTH spaces at left of line")
  565.  
  566. (defun zap_curr(old / lst num i nme )
  567.    (setq lst(wc_statistics) num(nth 13 lst) i (nth 18 lst))
  568.    (if(< num 2)
  569.       (progn
  570.          (wc_silent 0)
  571.          (wc_message "Attempt to delete buffer incorrect buffer" 0)
  572.          (quit)
  573.       )
  574.    )
  575.    (wc_new_file old)
  576.    (if ( > num 1)
  577.       (progn
  578.          (wc_remove_buffer i)
  579.       )
  580.    )
  581. )
  582.  
  583. (defun ins_crr()
  584.    (wc_break_line)
  585.    (wc_add_string "\n")
  586.    (wc_wrap_up)
  587. )
  588.  
  589. (defun print_file( ) ; / row col fstat len is OLDF crow flag )
  590.    (setq row (wc_row -1.0)col (wc_col -1.0) fstat(wc_statistics)
  591.       is(nth 3 fstat)  oldf(gcname) len (nth 2 fstat)
  592.       crow 0 flag 't down 60 page 1 page_st 50
  593.    )
  594.    ;(textscr)
  595.    ;(wc_cls)
  596.    (wc_window 20  1  60 6 1 1)
  597.    (wc_display 21 2 "  The  print options available  do  not" )
  598.    (wc_display 21 3 "  affect the current  file.   All  pre-")
  599.    (wc_display 21 4 "  processing is done in a spare buffer." )
  600.    (wc_display 21 5 "  Only text mode printing is supported."  )
  601.    (setq pconf(list 66 "NO" 50 "PRN" 5 3 3) flag 't a 0)
  602.    (while flag
  603.       (setq a
  604.          (wc_tmenu "══════ Print options Editor ══════" a
  605.             (list
  606.                (strcat " Lines per page:       " (itoa (nth 0 pconf))) ;0
  607.                (strcat " Include page numbers: " (nth 1 pconf))        ;1
  608.                (strcat " Column for page #:    "(itoa (nth 2 pconf)))  ;2
  609.                (strcat " Sent file to:         "(nth 3 pconf))         ;3
  610.                (strcat " Left margin:          "(itoa (nth 4 pconf)))  ;4
  611.                (strcat " Top margin:           "(itoa (nth 5 pconf)))  ;5
  612.                (strcat " Bottom margin:        "(itoa (nth 6 pconf)))  ;6
  613.                "Print the file "
  614.                "Exit to exitor "
  615.             )
  616.          )
  617.       )
  618.       (cond
  619.          ((= a 0)
  620.             (setq tempi(wc_fetch_int " Enter lines per page: " 3 (nth 0 pconf)))
  621.             (if (> tempi 0)
  622.                (setq pconf(list tempi (nth 1 pconf) (nth 2 pconf)(nth 3 pconf)(nth 4 pconf)(nth 5 pconf)(nth 6 pconf)))
  623.             )
  624.          )
  625.          ((= a 1)
  626.             (if(= (nth 1 pconf) "NO")
  627.                (setq pconf(list (nth 0 pconf) "YES" (nth 2 pconf)(nth 3 pconf)(nth 4 pconf)(nth 5 pconf)(nth 6 pconf)))
  628.                (setq pconf(list (nth 0 pconf) "NO" (nth 2 pconf)(nth 3 pconf)(nth 4 pconf)(nth 5 pconf)(nth 6 pconf)))
  629.             )
  630.          )
  631.          ((= a 2)
  632.             (setq tempi(wc_fetch_int " Enter Column for page #: " 3 (nth 2 pconf)))
  633.             (if (> tempi 0)
  634.                (setq pconf(list (nth 0 pconf)(nth 1 pconf) tempi(nth 3 pconf)(nth 4 pconf)(nth 5 pconf)(nth 6 pconf)))
  635.             )
  636.          )
  637.          ((= a 3)
  638.             (setq opt
  639.                (list
  640.                   "PRN"
  641.                   "LPT1"
  642.                   "LPT2"
  643.                )
  644.             )
  645.             (cond
  646.                ((= (nth 3 pconf)(nth 0 opt))
  647.                   (setq opt_def 0)
  648.                )
  649.                ((= (nth 3 pconf)(nth 1 opt))
  650.                   (setq opt_def 1)
  651.                )
  652.                ((= (nth 3 pconf)(nth 2 opt))
  653.                   (setq opt_def 2)
  654.                )
  655.             )
  656.             (setq k
  657.                (wc_tmenu " Printer output " opt_def
  658.                   (setq opt
  659.                      (list
  660.                         "PRN"
  661.                         "LPT1"
  662.                         "LPT2"
  663.                      )
  664.                   )
  665.                )
  666.             )
  667.             (if ( and (< k 3)(>= k  0))
  668.                (progn
  669.                   (setq pconf(list (nth 0 pconf)(nth 1 pconf) tempi(nth k opt)(nth 4 pconf)(nth 5 pconf)(nth 6 pconf)))
  670.                )
  671.             )
  672.          )
  673.          ((= a 4);Left margin
  674.             (setq tempi(wc_fetch_int " Enter Left Margin: " 3 (nth 4 pconf)))
  675.             (if (>= tempi 0)
  676.                (setq pconf(list (nth 0 pconf)(nth 1 pconf)(nth 2 pconf)(nth 3 pconf)tempi(nth 5 pconf)(nth 6 pconf)))
  677.             )
  678.          )
  679.          ((= a 5);Top margin
  680.             (setq tempi(wc_fetch_int " Enter Top Margin: " 3 (nth 5 pconf)))
  681.             (if (>= tempi 0)
  682.                (setq pconf(list (nth 0 pconf)(nth 1 pconf)(nth 2 pconf)(nth 3 pconf)(nth 4 pconf)tempi(nth 6 pconf)))
  683.             )
  684.          )
  685.          ((= a 6);Bot margin
  686.             (setq tempi(wc_fetch_int " Enter Bottom Margin: " 3 (nth 6 pconf)))
  687.             (if (>= tempi 0)
  688.                (setq pconf(list (nth 0 pconf)(nth 1 pconf)(nth 2 pconf)(nth 3 pconf)(nth 4 pconf)(nth 5 pconf)tempi))
  689.             )
  690.          )
  691.          ((= a 7)
  692.             (wc_message "Printing. Please wait..." 1)
  693.             (setq flag 't)
  694.             (if(= (nth 3 fstat) 0)
  695.                (progn
  696.                   (wc_race_home 2)
  697.                   (wc_trigger "BEGIN_LINE_MARK")
  698.                   (wc_race_end 2)
  699.                   (wc_trigger "END_MARK")
  700.                )
  701.             )
  702.             (setq down(nth 0 pconf))
  703.             (setq page_st(nth 2 pconf))
  704.             (setq page(nth 0 pconf))
  705.             (wc_trigger "DUMP_TO_SCRAP")
  706.             (wc_new_file "$TRASH$")
  707.             (wc_flush_buffer)
  708.            ;(wc_setvar "LAST_SCRAP" 1)
  709.             (wc_trigger "DUMP_SCRAP")
  710.             (if(> (nth 4 pconf) 0)
  711.                (repeat (atoi(rtos (nth 2 (wc_statistics)) 2 2));(nth 2 (wc_statistics))
  712.                   (wc_pad_left (nth 4 pconf))
  713.                   (wc_move_down 1.0)
  714.                )
  715.             )
  716.             (wc_race_home 2)
  717.             (setq len(nth 2 (wc_statistics))crow(wc_row -1.0))
  718.             (wc_col 0.0)
  719.             (while flag
  720.                (repeat(nth 5 pconf);Top margin
  721.                   (ins_crr)
  722.                   (wc_move_right 1.0)
  723.                )
  724.                (wc_stuff_char (wc_castchar 13))
  725.       (wc_move_down (atof(rtos(- page (+ (nth 6 pconf)(nth 5 pconf)))2 2)))
  726.                (setq crow(wc_row -1.0))
  727.                (if (<= crow len)
  728.                   (progn
  729.                      (wc_col 0.0)
  730.                      (wc_stuff_char (wc_castchar 12))
  731.                      (wc_move_right 1.0)
  732.                   )
  733.                   (setq flag nil)
  734.                )
  735.             )
  736.             (wc_race_home 2)
  737.             (wc_trigger "BEGIN_LINE_MARK")
  738.             (wc_race_end 2)
  739.             (wc_trigger "END_MARK")
  740.             (wc_trigger "DUMP_TO_SCRAP")
  741.             (wc_write_scrap (nth 3 pconf))
  742.             (zap_curr oldf)
  743.             (wc_row row)
  744.             (wc_col col)
  745.             (WC_refresh 1)
  746.             (setq flag nil)
  747.          )
  748.          (t
  749.             (setq flag nil)
  750.          )
  751.       )
  752.    )
  753. )
  754.  
  755. (wcconfig "print_FILE" 1.0 "Print the file or marked block")
  756.  
  757. ;;;This program will create an AutoLISP program for the current
  758. ;;;macro defined. The output is placed into macs.lsp.
  759. (defun create_lisp( / row col oldf flag len lst str is i crow key
  760.    name desc ans ll)
  761.    (setq row (wc_row -1.0)col (wc_col -1.0) lst(wc_statistics)
  762.       is(nth 3 lst)  oldf(gcname) len (nth 2 lst)
  763.       crow 0 flag 't
  764.    )
  765.    (setq lst(wc_get_macro))
  766.    (setq key(wc_message "Hit the key to assign" 0))
  767.    (if (/= key 283.0)
  768.       (progn
  769.          (setq name(wc_fetch_string "" " Enter a macro name " ""))
  770.          (setq desc(wc_fetch_string "" " Enter a description " ""))
  771.          (if (and name desc)
  772.             (progn
  773.                (wcconfig name key desc)
  774.                (wc_new_file "$TRASH$")
  775.                (wc_flush_buffer)
  776.                (wc_replace_line (strcat ";;;Macro: " desc))
  777.                (wc_move_down 1.0)
  778.                (wc_replace_line (strcat "(defun " name "(/ lst index)"))
  779.                (wc_move_down 1.0)
  780.                (wc_replace_line "(setq index 0 lst (list" )
  781.                (wc_move_down 1.0)
  782.                (setq index 0)
  783.                (repeat (length lst)
  784.                   (setq ll(wc_gfunc (nth index lst))str(wc_gname (nth index lst)))
  785.                   (if(not str)
  786.                      (setq str "Unknown key")
  787.                   )
  788.                   (if ll
  789.                      (wc_replace_line (strcat "(wc_first_key \"" (nth 1 ll) "\")" ))
  790.                      (wc_replace_line (strcat  (rtos (nth index lst) 2 1) " ;;;" str ))
  791.                   )
  792.                   (wc_pad_left (* 3 (wc_getvar "TABWIDTH")))
  793.                   (wc_move_down 1.0)
  794.                   (setq index(+ 1 index))
  795.                )
  796.                (wc_replace_line  "))")
  797.                (wc_move_down 1.0)
  798.                (wc_replace_line "(repeat (length lst)")
  799.                (wc_move_down 1.0)
  800.                (wc_replace_line "(wc_stuffkey (nth index lst))")
  801.                (wc_move_down 1.0)
  802.                (wc_replace_line "(setq index(+ 1 index))")
  803.                (wc_move_down 1.0)
  804.                (wc_replace_line ")")
  805.                (wc_move_down 1.0)
  806.                (wc_replace_line ");;;End macro")
  807.                (wc_move_down 1.0)
  808.                (wc_replace_line (strcat "(wcconfig \"" name "\" 1.0 \"" desc"\");;;Window register."))
  809.                (wc_trigger "PPRINT_ALL")
  810.                (wc_race_home 2)
  811.                (wc_trigger "BEGIN_LINE_MARK")
  812.                (wc_race_end 2)
  813.                (wc_trigger "END_MARK")
  814.                (wc_trigger "DUMP_TO_SCRAP")
  815.                (wc_flush_buffer)
  816.                (zap_curr oldf)
  817.                (if(setq str(findfile "MACS.LSP"))
  818.                   (WC_new_file str)
  819.                   (WC_new_file "MACS.LSP")
  820.                )
  821.                (wc_race_end 2)
  822.                (wc_move_down 2.0)
  823.                (wc_trigger "DUMP_SCRAP")
  824.                (wc_trigger "UHARD")
  825.                (load "MACS")
  826.                (zap_curr oldf)
  827.                (wc_row row)
  828.                (wc_col col)
  829.                (wc_message "Key is assigned and MACS.LSP is appended" 0)
  830.             )
  831.          )
  832.       )
  833.    )
  834. )
  835. (wcconfig "create_lisp" 1.0 "Create Lisp file from current macro.")
  836.  
  837. (defun rem_trail(str / i ch outstr)
  838.    (wc_trimends str)
  839. )
  840.  
  841. (defun c:shll()
  842.    (if(not __last_shll)
  843.       (setq __last_shll "")
  844.    )
  845.    (setq par(wc_fetch_string __last_shll " Enter DOS command " ""))
  846.    (if par
  847.       (progn
  848.          (if par
  849.             (setq par(rem_trail par))
  850.          )
  851.          (wc_cls)
  852.          (setvar "cmdecho" 0)
  853.          (setq emode (nth 19 (wc_statistics)))
  854.          (setq mouse (wc_getvar "UMOUSE"))
  855.          (wc_mouse 0)
  856.          (if(or(= emode 50)(= emode 43))
  857.             (wc_setmode_now 0)
  858.          )
  859.          (wc_cls)
  860.          (wc_setcurs 1 1)
  861.          (if par
  862.             (progn
  863.                (setq __last_shll par)
  864.                (command "sh" par)
  865.             )
  866.             (progn
  867.                (command "sh" "")
  868.             )
  869.          )
  870.          (wc_message "Press any key to return" 0)
  871.          (if(or(= emode 50)(= emode 43))
  872.             (progn
  873.                (wc_setmode_now 1)
  874.                (wc_setvar "UMOUSE" mouse)
  875.                (wc_mouse mouse)
  876.             )
  877.          )
  878.          (wc_refresh 1)
  879.       )
  880.    )
  881.    (prin1)
  882. )
  883.  
  884. (wcconfig "C:shll" 1.0 "Shell to DOS.")
  885.  
  886. (defun dispkey(i);0 trigger,1 External
  887.    (setq lst (wc_gfunc i))
  888.    (if lst
  889.       (progn
  890.          (if (= (nth 0 lst) 1)
  891.             (setq str "<E> ")
  892.             (setq str "")
  893.          )
  894.          (setq str (strcat str (nth 1 lst) " - " (nth 2 lst)))
  895.          (wc_message str 0)
  896.       )
  897.       (wc_message "Unknown" 0)
  898.    )
  899.    (prin1)
  900. )
  901.  
  902. (prin1)
  903.